package cn.itsource.basic.util;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Component;

@Component
public class EmailUtil {
    @Autowired
    private JavaMailSender javaMailSender;

    public void send(String to,String subject,String text){
        SimpleMailMessage mailMessage = new SimpleMailMessage();
        //设置发送人
        mailMessage.setFrom("517172018@qq.com");
        //邮件主题
        mailMessage.setSubject(subject);
        //邮件内容
        mailMessage.setText(text);
        //收件人
        mailMessage.setTo(to);

        javaMailSender.send(mailMessage);
    }
}
